package org.water.base.repository.hibernate;

import java.util.HashMap;
import java.util.Map;

import org.hibernate.transform.AliasedTupleSubsetResultTransformer;

public class AliasLowerToEntityMapResultTransformer extends AliasedTupleSubsetResultTransformer {

	public static final AliasLowerToEntityMapResultTransformer INSTANCE = new AliasLowerToEntityMapResultTransformer();

	  public Object transformTuple(Object[] tuple, String[] aliases)
	  {
	    Map result = new HashMap(tuple.length);
	    for (int i = 0; i < tuple.length; ++i) {
	      String alias = aliases[i];
	      if (alias != null) {
	        result.put(alias.toLowerCase(), tuple[i]);
	      }
	    }
	    return result;
	  }

	  public boolean isTransformedValueATupleElement(String[] aliases, int tupleLength)
	  {
	    return false;
	  }

	  private Object readResolve()
	  {
	    return INSTANCE;
	  }
}
